package day19;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;

/**
 * 使用转换流读取键盘录入
 * 当录入一行数据后，就将该行数据进行打印
 * 如果录入的数据是over，那么就停止录入
 * 
 * @author wangbiao
 *
 */
public class TransStreamDemo {

	public static void main(String[] args) {
		/*
		InputStream in = System.in;
		//定义转换流，将字节流转换成字符流。字节流通向字符流的桥梁
		InputStreamReader isr = new InputStreamReader(in);
		//为了提高读取的效率，定义字符流的缓冲流
		BufferedReader br = new BufferedReader(isr);
		
		PrintStream out = System.out;
		//字符流转换成字节流，字符流通向字节流的桥梁
		OutputStreamWriter osw = new OutputStreamWriter(out);
		//为了提高写入的效率，定义字符流的缓冲流
		BufferedWriter bw = new BufferedWriter(osw);
		*/
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
		String line = null;
		try {
			while ((line = br.readLine()) != null) {
				if ("over".equalsIgnoreCase(line)) {
					break;
				}
				bw.write(line);
				//换行
				bw.newLine();
				//将缓冲区里的数据刷新到控制台
				bw.flush();
			}
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			try {
				if (null != br) {
					br.close();
				}
				if(null != bw) {
					bw.close();
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}
}
